import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

public class MyBatisPlusGenerator {
    public static void main(String[] args) {
        String[] tables = {"sys_user","sys_role","sys_function","sys_user_role","sys_role_function","org_teacher","sys_dept","org_building","org_classroom","org_course","org_clazz","org_term","org_schedule","org_section","sys_log_login","sys_log_operate","sys_log_exception","push_record","push_record_detail"};
        DataSourceConfig dataSourceConfig = new DataSourceConfig
                .Builder("jdbc:mysql://8.130.25.73:3306/qywx", "gbw", "123456")
                .build();

        String projectPath = System.getProperty("user.dir");

        GlobalConfig globalConfig = new GlobalConfig.Builder()
                .outputDir(projectPath + "/src/main/java")
                .enableSwagger()
                .author("gbw")
                .disableOpenDir()
                .build();

        PackageConfig packageConfig = new PackageConfig.Builder()
                .moduleName("")
                .parent("cqie.sflab")
                .build();

        StrategyConfig strategyConfig = new StrategyConfig.Builder()
                .addInclude(tables)
                .controllerBuilder().enableRestStyle()
                .entityBuilder()
                .idType(IdType.ASSIGN_UUID)
                .enableChainModel()
                .enableLombok()
                .build();


        AutoGenerator autoGenerator = new AutoGenerator(dataSourceConfig);
        autoGenerator.global(globalConfig)
                .packageInfo(packageConfig)
                .strategy(strategyConfig);


        autoGenerator.execute(new FreemarkerTemplateEngine());
    }
}
